package com.ny.demo.proo;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        //一个实体类对应一个实体（表）：类对应一个表。类中的属性表中列名。。。。。
        //创建三个员工（工号，姓名，年龄）：创建一个员工类;创建三个员工对象
        //类名 对象名=new 类名（）；
        //把员工信息添加到集合中
    Employee employee1=new Employee();
    employee1.setNumber("1001");
    employee1.setName("哎哎");
    employee1.setAge(19);


    Employee employee2=new Employee();
    employee2.setNumber("1002");
    employee2.setName("欧欧");
    employee2.setAge(20);

    Employee employee3=new Employee();
    employee3.setNumber("1003");
    employee3.setName("妮妮");
    employee3.setAge(21);


    List<Employee> list = new ArrayList<>();
    list.add(employee1);
    list.add(employee2);
    list.add(employee3);

    for (int i=0;i< list.size();i++){
        System.out.println(list.get(i));
    }
    Scanner scanner = new Scanner(System.in);
    System.out.print("请输入要查询的员工工号：");
        //输出员工工号为1001的信息（用键盘输入)
        String number = scanner.next();

        boolean found = false;
        System.out.println("\n工号为" + number + "的员工信息：");
        for (Employee emp : list) {
            if (emp.getNumber().equals(number)) {
                System.out.println(emp);
                found = true;
            }
        }

        if (!found) {
            System.out.println("未找到该工号的员工信息！");
        }

        scanner.close();


    }
}
